from flask import jsonify
import json

class Result(object):
    def __init__(self, code=0, msg='', data=[]):
        self.code = code
        self.msg = msg
        self.data = data
    # 返回json字符串
    def ToJson(self):
        tmp = {}
        tmp['code'] = self.code
        tmp['msg'] = self.msg
        tmp['data'] = self.data
        return jsonify(tmp)


def result(success=1, code=0, msg='', data=[]):
    rdic = {}
    rdic["success"] = success
    rdic["code"] = code
    rdic["msg"] = msg
    rdic["data"] = data

    return json.dumps(rdic, ensure_ascii=False)
